#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>

int main()
{
   int fd = open("a.txt",O_CREAT | O_RDWR,0666);
   if(fd == -1) perror("open") , exit(-1);
   char ch ;
   read(fd , &ch , 1);
   printf("%c\n",ch);
   read(fd , &ch , 1);   
   printf("%c\n",ch);

   lseek(fd , 2 , SEEK_SET);
   write(fd , "1" , 1);
   lseek(fd , 2 , SEEK_CUR);
   write(fd , "2" , 1);
   lseek(fd , -2 , SEEK_END);
   write(fd , "3" , 1);
   
   close(fd);
}
